function [a,param] = eeInt(param,Q,sAVisit,sADisc,aF,n)
%
% explore (undirected, or max uncertainty!!) / exploit pick max action in
% the case of the GP interpolation approach. at this point, we still work
% with discretized state/action-spaces. Later, a fully parametrized version
% of the Q-function will be implemented.
%
% Tobias Siegfried, 10/01/2008

if param.hydroGuy(n) % improve that later on!
    Q = Q - param.QOffset;
end

qI = find(Q);

if param.countI > param.minRandGP %~ isempty(qI)
    
    [sI,aI] = find(Q); indI = sub2ind(size(Q),sI,aI);
    x1 = param.stateV{n}(sI)'; x2 = param.actionV{n}(aI); x = [x1 x2];
    covfunc = {'covSum', {'covSEiso','covNoise'}};
    loghyper = [log(1.0); log(1.0); log(0.1)]; % this is the parameterization that needs to be adequatly dealt with, obv.
    
    % compute interpolation
    [mu s2] = gpr(loghyper, covfunc, x, Q(indI), sADisc); % predictions
    
    if n == 1 % improve that later on!
        mu = mu + param.QOffset;
    end 
    
    muS = reshape(mu,size(Q,1),size(Q,2));
    s2S = reshape(s2,size(Q,1),size(Q,2));
    
    keyboard
    
else % pick random actions just for the first few times.
    
    m = aF >= param.actionV{n};
    a = rand * aF; % undirected action selection
    param.countI = param.countI + 1;
    
end